<?php
require(dirname(__FILE__) . '/includes/init.php');
if($_REQUEST['act'] == 'search'){
	$sku = $_REQUEST['products_sn'];
	$sql = "select * from ".$ecs->table('yihaodian')." where products_sn='".$sku."' order by id desc";
	$goods_list = $db->getAll($sql);
	foreach($goods_list as $i=>$goods){
		$goods_list[$i]['ye_num'] = (int)(($goods['ranking']-1)/36+1);
		$goods_list[$i]['add_time'] = date('Y-m-d H:i:s',$goods['add_time']);
	}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理中心 - SKU查询 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
 
<h1>
<span class="action-span1"><a target="_top" href="index.php?act=main">管理中心</a> </span><span id="search_id" class="action-span1"> - SKU查询 </span>
<div style="clear:both"></div>
</h1>

<div class="form-div">
  <form action="yihaodian_d.php" method="post" name="searchForm" onsubmit="return search_yz()">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    SKU<input name="products_sn" type="text" id="products_sn" size="15">
	<input type="hidden" name="act" value="search" />
    <input type="submit" value=" 搜索 " class="button" />
  </form>
</div>
<script type="text/javascript">
function search_yz(){
	var products_sn = $("#products_sn").val();
	if(products_sn==""){
		alert("请输入搜索条件");
		return false;
	}else{
		return true;
	}
}
</script> 
<!-- 订单列表 -->
  <div class="list-div" id="listDiv">
  <div><span style="font-size:16px;">SKU:<?php echo $goods_list[0]['products_sn'];?>，商家:<?php echo  $goods_list[0]['provider'];?>，产品名:<a href="http://www.yihaodian.com/product/<?php echo $goods_list[0]['products_sn'];?>" target="_blank"><?php echo  $goods_list[0]['products_name'];?></a></div>
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>排名</th>
    <th>所在页</th>
    <th>评价总数</th>
	<th>价格</th>
	<th>时间</th>
  <tr>
  <?php 
    $i=0;
	if(count($goods_list)>0){
	foreach($goods_list AS $index => $array_val){
		$i++;
  ?>
   <tr>
    <td><?php echo $array_val['ranking'];?><span style="color:red">
	<?php 
	if(!$goods_list[$index+1]['ranking']){
	  echo '';
	}else{ 
		$cha = $goods_list[$index+1]['ranking']-$goods_list[$index]['ranking'];
		if($cha==0){
			echo '--';
        }elseif($cha>0){
			echo '↑'.$cha;
		}else{
			echo '↓'.abs($cha);
		}
	}
	?>
    <td><?php echo $array_val['ye_num'];?></td>
    <td><?php echo $array_val['commentcount'];?><span style="color:red">
	<?php 
	if(!$goods_list[$index+1]['commentcount']){
	  echo '';
	}else{ 
		$cha = $goods_list[$index+1]['commentcount']-$goods_list[$index]['commentcount'];
		if($cha==0){
			echo '--';
        }elseif($cha>0){
			echo '↓'.$cha;
		}else{
			echo '↑'.abs($cha);
		}
	}
	?>
	</span>
	</td>
	<td><?php echo $array_val['price'];?></td>
	<td><?php echo $array_val['add_time'];?></td>
  <tr>
  <?php 
      } 
	}
  ?>
  </table>
 
<!-- 分页 -->
  </div>
</body>
</html>